<?php 
	jimport('joomla.application.component.controller');
	//require 'components/com_kinh_doanh/tables/kinh_doanh.php';

	
	class order_branchControllerchuyen_hang extends JController
	{
	    function van_chuyen()
        {
           $model =$this->getModel("chuyen_hang");
           $date=$_POST['date'];
           $data = $model->su_luoc_nhan_don_hang($date);
           
           foreach($data as $row)
           {
                if(isset($_POST["bill".$row->id]))  
                    {
                        
                        $data2 = $model->ds_sp_bill($row->id);
                        foreach($data2 as $row2)
                        {
                            $data3 = $model->lay_consig_theo_id_pro($row2->id_pro);
                            foreach($data3 as $row3)
                            {
                                if($_POST["consig".$row3->id_product] == $row3->consignment_code)
                                {
                                    
                                    //giam so luong o khong erp_warehouse_ex_pro
                                    $model->cap_nhat_so_luong($row2->id_pro,$_SESSION['id_kho'],$row3->consignment_code,$row2->number,$row->id);
                                }
                            }
                            //echo "<pre>";print_r($data2);echo "</pre>";
                        }
                        
                    }
           }
           $this->setRedirect("index.php?option=com_order_branch&task=chuyen_hang","thanh cong");   
	    }
        function danh_sach_kho()
        {
            JRequest::setVar('view','danh_sach_kho'); 
			parent::display();
        }
        function chuyen_hang()
        {
            
            JRequest::setVar('view','chuyen_hang'); 
			parent::display();  
        }

    }
?>